package com.hb.trade.server.project.section.service.status;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hb.core.pojo.enums.SectionStatusEnum;
import com.hb.core.pojo.project.opening.entity.OpeningBidInfo;
import com.hb.core.pojo.project.section.dto.BidSectionDTO;
import com.hb.trade.server.project.opening.service.OpeningBidHallService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.stereotype.Service;

/**
 * 开标结束判断逻辑
 *
 * @author zhaojk
 * @deprecated 产品已经移除该状态
 */
@Setter
@Getter
@Deprecated
public class BidOpenEnd implements CalSectionStatus {

    /**
     * 排序号
     */
    private Integer sortCode = 148;

    private final OpeningBidHallService openingBidHallService;

    public BidOpenEnd(OpeningBidHallService openingBidHallService) {
        this.openingBidHallService = openingBidHallService;
    }

    @Override
    public Long getSectionStatus(BidSectionDTO section) {
        // 查询开标信息
        QueryWrapper<OpeningBidInfo> wrapper = OpeningBidInfo.wrapper("status");
        wrapper.eq("section_id", section.getId()).last("limit 1");
        OpeningBidInfo openingBidInfo = openingBidHallService.getOne(wrapper);
        if (openingBidInfo == null) {
            return null;
        }

        // 当前标段的审核状态
        // FIXME 目前业务中没有涉及询比价开启结束的标识  需要通过报价截止时间判断
        // 这里type为6和7时仅限于判断有开标大厅的项目类型
/*        Integer status = openingBidInfo.getStatus();
        if (Integer.valueOf(6).equals(status) || Integer.valueOf(7).equals(status)) {
            return SectionStatusEnum.OPEN_BID_END.getId();
        }*/
        return null;
    }

    @Override
    public Integer getSort() {
        return sortCode;
    }
}
